//
// Created by 11510 on 2024/6/9.
//

#ifndef CNTWORD_DICTIONARY_H
#define CNTWORD_DICTIONARY_H
#include <string>
#include <vector>
using std::string;
using std::vector;

struct Record{
    string _word;
    int _frequency;
    /*有参构造*/
    Record(const string& word, int frequency)
    :_word(word), _frequency(frequency){}
};


class Dictionary {
public:
    void read(const string &filename);
    void store(const string &filename);

    Dictionary(){
        _dict.reserve(1000);
    }

    Dictionary(int capacity){
            _dict.reserve(capacity);
    }

    ~Dictionary();


private:
    vector<Record*> _dict;

    bool isWord(const std::string& str);

    bool isExistThisWordInDict(const string &word);
};


#endif //CNTWORD_DICTIONARY_H
